//
//  DropView.m
//  UploadFnta
//
//  Created by Florent Jardin on 02/12/09.
//  Copyright 2009 fnta.me All rights reserved.
//

#import "DropView.h"


@implementation DropView

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
		[self registerForDraggedTypes:[NSArray arrayWithObjects:
										NSFilenamesPboardType, nil]];
    }
    return self;
}

- (void)drawRect:(NSRect)dirtyRect {
	NSImage *image = [NSImage imageNamed:@"fntastatus.png"];
	NSRect imageRect;
	imageRect.origin = NSZeroPoint;
	imageRect.size = [image size];
	NSRect drawingRect = imageRect;
	[image drawInRect:drawingRect fromRect:imageRect operation:NSCompositeSourceOver fraction:1.0];
}

- (void)mouseDown:(NSEvent*)event
{
}

#pragma mark Dragging Destination
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
    NSPasteboard *pboard;
    NSDragOperation sourceDragMask;
 
    sourceDragMask = [sender draggingSourceOperationMask];
    pboard = [sender draggingPasteboard];
 
    if ( [[pboard types] containsObject:NSPasteboardTypeString] ) {
        if (sourceDragMask & NSDragOperationLink) {
            return NSDragOperationCopy;
        } else if (sourceDragMask & NSDragOperationCopy) {
            return NSDragOperationCopy;
        }
    }
    return NSDragOperationNone;
}

- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
    NSPasteboard *pboard;
    NSDragOperation sourceDragMask;
 
    sourceDragMask = [sender draggingSourceOperationMask];
    pboard = [sender draggingPasteboard];
 
	if ([[pboard types] containsObject:NSPasteboardTypeString]) {
        NSLog(@"Woot :D");
    }
    return YES;
}

@end
